package 力扣;

import Stack.Stack;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yyq
 * @create 2022-03-28 10:03
 */
public class leetcode232 {

}
class MyQueue {

    Stack<Integer> list;
    Stack<Integer> temp;

    public MyQueue() {

        list=new Stack<Integer>();
        temp=new Stack<Integer>();
    }

    public void push(int x) {
        list.push(x);

    }

    public int pop() {
        while (!list.isEmpty()){
            temp.push(list.pop());
        }
        int pop=temp.pop();
        while(!temp.isEmpty()){
            list.push(temp.pop());
        }
        return pop;

    }

    public int peek() {
        while (!list.isEmpty()){
            temp.push(list.pop());
        }
        int pop=temp.pop();
        list.push(pop);
        while(!temp.isEmpty()){
            list.push(temp.pop());
        }
        return pop;

    }

    public boolean empty() {
        if(list.isEmpty()) return true;
        else return false;

    }
}
